home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / bbsutil / watchkit.zip / WATCHKIT.ASM < prev    next >
Assembly Source File  |  1990-01-09  |  7KB  |  292 lines

  1.  page ,132
  2.  .model tiny
  3.  .code
  4. first:
  5. ;
  6. ; [This is WATCHKIT.  Should work with 2 hours and 4 rings. -jason reyes]
  7. ;
  8. ; WATCHCAT copyright 1989, Joseph R. Ahlgren
  9. ;  see WATCHCAT.DOC
  10. ;
  11. ; WATCHCAT performs 5 critical functions for any RBBS system:
  12. ;  1.  Reboots system if no carrier in specified period of time
  13. ;    This catches RBBS or system failures
  14. ;  2.  Reboots system if carrier lost during critical period
  15. ;    This allows Doors to be used safely
  16. ;  3.  Reboots system if 20 rings without answering phone
  17. ;    This allows system to be restarted by phone
  18. ;  4.  Reboots system if "Hit any key to return to system" message appears
  19. ;    This restarts system on a common RBBS failure
  20. ;  5.  Drops carrier if L&R shift keys pressed simultaneously
  21. ;    This allows users to be logged off without a nasty message.
  22. ;WATCHCAT loads the TSR and disables all functions
  23. ; WATCHCAT OFF disables all functions
  24. ; WATCHCAT ON enables 1,3,4,and 5
  25. ; WATCHCAT TIMER enables 2,4,and 5
  26. ;ComPort = 03f8h  ;{COM1}
  27. ;ComPort = 02f8h  ;{COM2}
  28. ;ComPort = 03e8h  ;{COM3}
  29. ;ComPort = 02e8h  ;{COM4}
  30. ;ScreenSegment = 0b800h  ;{Color}
  31. ;ScreenSegment = 0b000h  ;{Mono}
  32. ModemStatus = 0006h
  33. ModemControl = 0004h
  34. CarrierDetect = 0080h
  35. RingIndicator = 0040h
  36. tpm = 1092 ; {ticks per minute}
  37. RingTicks = 110; {6 seconds}
  38.  org 100h
  39. start:
  40.  jmp init
  41. RingTrigger dw 0
  42. RingTimer db 0
  43. Flag db 'F' and 0fh  ;  OFF ON TIME = F O I
  44. TimerInt dd ?
  45. ; Minutes dw 8*60  ;{minutes of no carrier to trigger reset}
  46. Minutes dw 2*60  ;{minutes of no carrier to trigger reset} [2 hours -jr]
  47. Seconds dw tpm
  48. ; MinReset dw 8*60
  49. MinReset dw 2*60    ; [2 hours -jr]
  50. ColdBoot dd 0ffff0000h
  51. ExitTimer db 0
  52. DropTrigger db 3  ;Drop DTR on L&R shift
  53. ExitMessage db 'Hit any key to return to system'
  54. ExitMessageEnd db 0
  55. ComPort dw 02f8h  ;{COM2}
  56. ScreenSegment dw 0b000h  ;{Mono}
  57. Ident db "jOeY"
  58. Ident2 db "50c4"
  59. timer:
  60.  assume ds:nothing,es:nothing,ss:nothing
  61.  cmp cs:[Flag],'F' and 0fh
  62.  jne SystemOn
  63.  jmp cs:[TimerInt]
  64. SystemOn:
  65.  push ax
  66.  push dx
  67.  push ds
  68. ;  4.  Reboots system if "Hit any key to return to system" message appears
  69. ;    This restarts system on a common RBBS failure
  70.  dec cs:[ExitTimer]
  71.  jnz NoExitLoop
  72.  push cx
  73.  push si
  74.  push di
  75.  mov ax,cs:[ScreenSegment]
  76.  mov ds,ax
  77.  mov cx,25
  78.  xor si,si
  79. SSLoop1:
  80.  push cx
  81.  push si
  82.  mov cx,ExitMessageEnd-ExitMessage
  83.  mov di,offset ExitMessage
  84. SSLoop2:
  85.  lodsw
  86.  cmp al,cs:[di]
  87.  jne SSLoop2x
  88.  inc di
  89.  loop SSLoop2
  90.  jmp short NoCarrier
  91. SSLoop2x:
  92.  pop si
  93.  pop cx
  94.  add si,160
  95.  loop SSLoop1
  96.  pop di
  97.  pop si
  98.  pop cx
  99. NoExitLoop:
  100. ;  5.  Drops carrier if L&R shift keys pressed simultaneously
  101. ;    This allows users to be logged off without a nasty message.
  102.  xor ax,ax
  103.  mov ds,ax
  104.  assume ds:Lowmem
  105.  mov al,[ShiftStatus]
  106.  and al,0fh
  107.  cmp al,cs:[DropTrigger]
  108.  jne NoShift
  109.  mov dx,cs:[ComPort]
  110.  add dx,ModemControl
  111.  in al,dx
  112. ; or al,1
  113.  and al,0feh
  114.  out dx,al       ;drop DTR
  115. NoShift:
  116. ;  3.  Reboots system if 20 rings without answering phone
  117. ;    This allows system to be restarted by phone
  118.  mov dx,[ComPort]
  119.  add dx,ModemStatus
  120.  in al,dx
  121.  test al,RingIndicator
  122.  jz NotRinging
  123.  or cs:[RingTrigger],1
  124. NotRinging:
  125.  dec cs:[RingTimer]
  126.  jnz NoRingTime
  127.  mov cs:[RingTimer],RingTicks
  128.  mov ax,cs:[RingTrigger]
  129. ; or ax,0f000h              ;P Eibl [supposed to be 15 rings -jr]
  130.  or ax,0fff0h              ; [this should do 4 rings -jr]
  131.  cmp ax,0ffffh        ; [does 16 bits ON mean 20 rings ? -jr]
  132.  je NoCarrier
  133.  shl ax,1
  134.  mov cs:[RingTrigger],ax
  135. ;  2.  Reboots system if carrier lost during critical period
  136. ;    This allows Doors to be used safely
  137. NoRingTime:
  138.  cmp cs:[Flag],'I' and 0fh
  139.  jb NoMonitor
  140.  je TimeCheck
  141.  in al,dx
  142.  and al,CarrierDetect
  143.  jz NoCarrier
  144. NoMonitor:
  145.  pop ds
  146.  pop dx
  147.  pop ax
  148.  jmp cs:[TimerInt]
  149. NoCarrier:
  150.  jmp cs:[ColdBoot]
  151. ;  1.  Reboots system if no carrier in specified period of time
  152. ;    This catches RBBS or system failures
  153. TimeCheck:
  154.  test al,CarrierDetect
  155.  jnz ResetTime
  156.  dec cs:[Seconds]
  157.  jnz NoMonitor
  158.  mov cs:[Seconds],tpm
  159.  dec cs:[Minutes]
  160.  jz NoCarrier
  161.  jmp short NoMonitor
  162. ResetTime:
  163.  mov ax,cs:[MinReset]
  164.  mov cs:[Minutes],ax
  165.  jmp short NoMonitor
  166. ;
  167. ;
  168. ;
  169. ;
  170.  assume ds:@code,es:@code,ss:@code
  171. init:
  172.  mov dx,offset SignOnMessage
  173.  mov ax,0900h
  174.  int 21h     ;print load message
  175.  mov ax,[word ptr Ident2]
  176.  xor [word ptr Ident],ax
  177.  mov ax,[word ptr Ident2+2]
  178.  xor [word ptr Ident+2],ax
  179.  xor dx,dx
  180.  mov es,dx
  181.  mov si,offset Ident
  182.  mov cx,cs
  183.  mov ax,[si]
  184. findloop:
  185.  cmp ax,es:[si]
  186.  jz found
  187. NotQuite:
  188.  inc dx
  189.  mov es,dx
  190.  loop findloop
  191. LoadWatchCat:
  192.  xor bx,bx
  193.  mov es,bx
  194.  mov bl,ds:[82h]
  195.  cmp bl,'0'
  196.  jle NoCom
  197.  cmp bl,'4'
  198.  jle ComSpec
  199. NoCom:
  200.  mov bl,'1'
  201. ComSpec:
  202.  mov [ComPortNumber],bl
  203.  add bx,bx
  204.  mov ax,es:[bx+400h-31h-31h]
  205.  mov [ComPort],ax
  206.  cmp byte ptr ds:[83h],'C'
  207.  jnz NotColor
  208.  mov [ScreenSegment],0b800h
  209.  mov [ScreenSegNum],'8'
  210. NotColor:
  211.  mov ax,3508h
  212.  int 21h     ;get timer interrupt
  213.  mov [word ptr TimerInt],bx
  214.  mov [word ptr TimerInt+2],es
  215.  mov dx,offset Timer
  216.  mov ax,2508h
  217.  int 21h     ;set timer interrupt
  218.  mov dx,offset message1
  219.  mov ax,0900h
  220.  int 21h     ;print load message
  221.  mov dx,(init-first+15)/16
  222.  mov ax,3101h
  223.  int 21h      ;TSR
  224. Found:
  225.  mov bx,[si+2]
  226.  cmp bx,es:[si+2]
  227.  jnz NotQuite
  228.  mov ax,es
  229.  mov bx,10h
  230.  mov di,offset message2x
  231.  mov cx,4
  232. loc:
  233.  mul bx
  234.  cmp dl,9
  235.  jbe locx
  236.  add dl,7
  237. locx:
  238.  add dl,'0'
  239.  mov [di],dl
  240.  inc di
  241.  loop loc
  242.  mov ax,es:[MinReset]
  243.  mov es:[Minutes],ax
  244.  mov al,ds:[83h]
  245.  and al,0fh
  246.  mov es:[Flag],al
  247.  mov dx,offset message2tim
  248.  cmp al,'I' and 0fh
  249.  jz done
  250.  mov dx,offset message2off
  251.  jb done
  252.  mov dx,offset message2on
  253. done:
  254.  push dx
  255.  mov dx,offset message2
  256.  mov ax,0900h
  257.  int 21h
  258.  pop dx
  259.  mov ax,0900h
  260.  int 21h
  261.  mov ax,4c00h
  262.  int 21h
  263. message1 db 0ah,0dh,'Watchcat Loaded, set to COM'
  264. ComPortNumber db '1 and Screen B'
  265. ScreenSegNum db '000',0ah,0dh,'$'
  266. message2 db 0ah,0dh,'Watchcat found at '
  267. message2x db '0000 and set to $'
  268. message2on db 'ON',0ah,0dh,'$'
  269. message2off db 'OFF',0ah,0dh,'$'
  270. message2tim db 'TIMER',0ah,0dh,'$'
  271. SignOnMessage db 0dh,0ah,'WATCHCAT, copyright 1989 Joseph R. Ahlgren'
  272.  db '   RBBS 703-241-7980',0dh,0ah
  273.  db ' WATCHCAT may be freely distributed provided this message is not modified',0dh,0ah
  274.  db ' Load with WATCHCAT ps, where p is the port number (1,2,3,4)',0dh,0ah
  275.  db '  and s is the screen type (Color or Mono), e.g., WATCHCAT 2C',0dh,0ah
  276.  db '  specifies COM2 and Color Screen',0ah,0dh
  277.  db ' Subsequent calls are WATCHCAT ON, WATCHCAT OFF, and WATCHCAT TIMER',0dh,0ah
  278.  db '  OFF disables all functions',0dh,0ah
  279.  db '  ON reboots if carrier lost',0dh,0ah
  280.  db '  TIMER reboots if 20 rings without answering phone, if no carrier',0dh,0ah
  281.  db '   in 8 hours, or if "Hit any key to return to system" appears on screen',0dh,0ah
  282.  db '   Also, pressing both Left and Right Shift keys simultaneously will',0dh,0ah
  283.  db '   drop the line, logging off the current user.',0dh,0ah
  284.  db '$'
  285.  ends
  286. Lowmem segment at 0000h
  287.  org 417h
  288. ShiftStatus db ?
  289. Lowmem ends
  290.  end start
  291.  
  292.